import request from '@/utils/request'

// 登录接口
export const getLogin = (data) => {
  return request({
    method: 'POST',
    url: 'login',
    data
  })
}
// 用户管理数据
export const getUser = (params) => {
  return request({
    method: 'GET',
    url: '/users',
    params
  })
}
// 添加数据
export const addUser = (data) => {
  return request({
    method: 'POST',
    url: '/users',
    data
  })
}
// 删除数据
export const delUser = (id) => {
  return request({
    method: 'DELETE',
    url: `/users/${id}`
  })
}
// 获取用户详情
export const getOneUser = (id) => {
  return request({
    method: 'GET',
    url: `/users/${id}`
  })
}
// 修改用户信息详情
export const xiugaiOneUser = (id, data) => {
  return request({
    method: 'PUT',
    url: `/users/${id}`,
    data
  })
}
// 获取角色列表
export const fenPeiUser = () => {
  return request({
    method: 'GET',
    url: '/roles'
  })
}
// 分配用户详情
export const fenPeiUser2 = (id, role) => {
  return request({
    method: 'PUT',
    url: `/users/${id}:${role}`,
    data: {
      id: role
    }
  })
}
// 修改用户状态
// 分配用户详情
export const xiugaiZhuangTai = (id, bool) => {
  return request({
    method: 'PUT',
    url: `/users/${id}/state/${bool}`
  })
}
